<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xml:lang="pt" lang="pt-br">

<f:view contentType="text/html">
	<h:head>
		<f:facet name="first">
			<meta http-equiv="X-UA-Compatible" content="EmulateIE8" />
			<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
			<title>Sos:Usuarios</title>
		</f:facet>
		<h:outputStylesheet name="css/default.css" />
		<h:outputStylesheet name="css/estilo.css" />
	</h:head>
	<h:body>
		<p:layout id="seila" fullPage="true">
			<p:layoutUnit id="bottom" position="south" size="30">
				<ui:include src="../rodape.xhtml" />
			</p:layoutUnit>
			<p:layoutUnit id="center" position="center">

				<div id="menu">
					<ui:include src="../menu.xhtml" />
				</div>
				
				<div id="pesq" align="center">
					<h:form id="pesquisa">
						<h:panelGrid id="painelGrid" columns="5">
						
							<h:outputText id="nomePesq" value="Nome: " />
							<p:inputText id="pesqNome" value="#{usuarioManager.nomeUsuario}" size="50" />

							<p:commandButton id="buttonPesquisa" value="Pesquisar"
								title="Para exibir todos apenas click em Pesquisar"
								actionListener="#{usuarioManager.listaUsuariosPorNome()}"
								ajax="false" update="seila,corpo" />
								
						</h:panelGrid>
					</h:form>
				</div>
				
				<div id="corpo">
				<p:messages id="mensagem" showDetail="true" redisplay="false" autoUpdate="true" closable="true" />
					<h:form id="teste">
						<p:dataTable id="tabelaFunc" var="user" paginator="true" rows="10" style="box-shadow: 1px 5px 15px 1px #888;"
							value="#{usuarioManager.listAdmin}" emptyMessage="Nenhum registro encontrado." >
							
							<f:facet name="header">
					        	Lista de Usuários
					        </f:facet>

							<p:column headerText="Nome">
								<h:outputText value="#{user.nome}" />
							</p:column>

							<p:column headerText="Email">
								<h:outputText value="#{user.email}" />
							</p:column>

							<p:column style="width: 5%" rendered="#{permissaoManager.canEdit()}" >
								<f:facet name="header">Editar</f:facet>
								<p:commandButton ajax="false"
									action="#{usuarioManager.pegar(user)}" id="editButton"
									icon="ui-icon-pencil" title="Editar" />
							</p:column>

							<p:column style="width: 5%" rendered="#{permissaoManager.canDelete()}" >
								<f:facet name="header">Excluir</f:facet>
								<p:commandButton update="corpo" ajax="false"
									action="#{usuarioManager.deletar(user)}" id="deleteButton"
									icon="ui-icon-closethick" title="Deletar" />
							</p:column>

						</p:dataTable>
					</h:form>
				</div>
				
			</p:layoutUnit>
		</p:layout>
	</h:body>
</f:view>
</html>